#include "coin.hpp"
using namespace QuantumWalk;

typedef gen_op::ptr_t ptr_t;

template<typename T>
coin<T>::coin(const matrix<T>& c, int d, int v):gen_op(d,v){
  c_=c;
}

template<typename T> 
void coin<T>::set_op(const matrix<T>& c){
  c_=c;
}

template<typename T>
matrix<T> coin<T>::get_op(){
  return c_;
}

template<typename T>
coin<T>::coin(const coin<T>& C):gen_op(C){
  if(this != &C){
    c_=C.c_;
  }
}

template<typename T>
coin<T>& coin<T>::operator=(const coin& C){
  if(this != &C){
    c_=C.c_;
    this->dimV_=C.dimV_;
    this->dimD_=C.dimD_;
  }
  return *this;
} 


template<typename T> 
T coin<T>::operator()(int i,int j) const{
  return c_(i,j);
}

template<typename T> 
int coin<T>::get_dim() const{
  //return c_.size1();
  return this->dimD_;
}


template<typename T> 
ptr_t coin<T>::pointer(){
  return this;
}

template<typename T> 
matrix<T> coin<T>::asmatrix(){
  int N=this->dimV_ * this->dimD_;
  matrix<T> ret(N,N,0);
  for(int i=0;i<this->dimD_;i++){
    for(int j=0;j<this->dimD_;j++){
      for(int k=0;k<this->dimV_;k++){
	int r_idx=this->two_to_one(i,k);
	int c_idx=this->two_to_one(j,k);
	
	ret(r_idx,c_idx)=c_(i,j);
      }
    }
  }
  return ret;
}

template class coin<std::complex<double> >;
template class coin<double>;



